#pragma once  
  
extern "C"
{
#include "../../include/mqtt/MQTTAsync.h" 
}

#include "../../include/common/threadLock.h"
 
#include "../../include/common/base.h"
  
#include "../../include/fore/mqtt_msg.h"


#define ADDRESS     "tcp://127.0.0.1:1883"
#define QOS         1
   
class CMyMQTTAsync
{  
public:  
    CMyMQTTAsync();  
    ~CMyMQTTAsync();  
	

	MQTTAsync 					m_client; 
	
	bool    connect_mqtt(char* pub_topic_clientID, char * mqtt_svr_addr,  MQTTAsync_messageArrived *  my_fun, void* context = NULL);
 
	bool	send_msg(char* topic, char* msg, unsigned short msg_len, unsigned char msg_format );
	

	void	subscribe_topic(char* topic); 

	bool	Send_Reply_pack(char * topip, char * chrToken, int statusCode, char* statusDesc,  char * errorDesc, char* errorTag);

 
public:
	bool analyse_confirm( const char * json );
	//bool analyse_result( const char * json );
	void SetResultVal(bool b);

	bool  IsCurrentTopic(char* topic );

	void   send_string( int qos, char* pTopic,  char * msg_data );
	void   send_msg( int qos, char* pTopic, char * msg_data, unsigned short msg_len );
 
private:
	
	
	void disconnect();
	
	std::vector<std::string>   m_arySubTopic ;  

	//CThreadLock			m_subsrcibe_threadLock; 
	int					m_my_result_val;

	 
	
};
